//import 'package:cached_network_image/cached_network_image.dart';
import 'package:flutter/material.dart';

//网络图片缓存控件
class CachedNetworkImageLoader extends StatelessWidget {
  final String imageUrl;
  final BoxFit? fit;

  final double progressIndicatorStrokeWidth;
  const CachedNetworkImageLoader(
      {super.key,
      required this.imageUrl,
      this.progressIndicatorStrokeWidth = 4.0,
      this.fit});

  @override
  Widget build(BuildContext context) {
    Widget loadingWidget = Center(
      child: CircularProgressIndicator.adaptive(
        strokeWidth: progressIndicatorStrokeWidth,
      ),
    );

    Widget placeholderWidget = Container(
      alignment: Alignment.center,
      child: const Icon(
        Icons.image,
        size: 44,
      ),
    );

    // Widget imageWidget = CachedNetworkImage(
    //   imageUrl: imageUrl,
    //   fit: fit ?? BoxFit.cover,
    //   // imageBuilder: (context, imageProvider) => Container(
    //   //   decoration: BoxDecoration(
    //   //     borderRadius: BorderRadius.circular(8.0), // 添加圆角
    //   //   ),
    //   //   child: Image(image: imageProvider, fit: BoxFit.fill),
    //   // ),
    //   progressIndicatorBuilder: (context, url, downloadProgress) {
    //     if (downloadProgress.progress == 1.0) {
    //       return placeholderWidget;
    //     } else {
    //       return loadingWidget;
    //     }
    //   },
    //   errorWidget: (context, url, error) => placeholderWidget,
    // );

    return const Text("data");
  }
}


/*

CachedNetworkImageLoader(
                            imageUrl: widget.model.thumb,
                          )
*/